<template>
	<div class="collection-container">
		<!-- 商品列表区域 -->
		<div v-for="(item, i) in collectionList" :key="i" style="margin-top: 1rem;">
			<van-row type="flex" align="center" >
				<van-col span="4">
					<!-- 中间商品图片 -->
					<van-image radius="20px"  :src="APIDomainName + item.pic"></van-image>
				</van-col>
				<van-col span="14" offset="1" style="display: flex;justify-content: space-between;">
					<div>
						<div style="font-size: 22px;margin-bottom: 0.5rem;font-weight: 600;">{{ item.title }}</div>
						<div style="font-size: small;color: #888B90;">{{item.id}}万+人收藏</div>
					</div>
				</van-col>
				<van-col span='5'>
					<van-button plain round   style="background-color: #FFFFFF; color: #01CBE2;border-color: #01CBE2;width: 100%;font-weight: bold;font-size: 15px;height: 2.5rem;" @click="onDetail(item.product_id)">
						查看详情
					</van-button>
				</van-col>
			</van-row>
			<div style="height: 0.1rem;background-color: #EDEFEE;margin: 1rem 0;"></div>
		</div>
		<div style="font-size: 16px;color: #BABEC1;text-align: center;margin-top: 2rem;">暂无更多</div>

	</div>
</template>

<script>
	import {
		getCollectionListAPI,
	} from "@/api/collection.js";
	import {
		getProductAPI,
	} from "@/api/product.js";
	export default {
		data() {
			return {
				collectionList: [],
			};
		},
		created() {
			this.getCollectionData();
		},
		methods: {
			getCollectionData() {
				this.collectionList = []; //清空
				getCollectionListAPI().then(result => {
					this.collectionList = result.data;
				}).catch(() => {});
			},
			// 单击左菜单中的某一项后，显示对应分类的商品列表

			onDetail(id) {
				this.$router.push({
					name: 'productDetail',
					params: {
						id
					},
				});
			}
		}
	};
</script>



<style lang="less" scoped>
	.collection-container {
		padding:0 20px 20px 20px;

		.collection_header {
			//padding: 10px;
			//margin: 10px 0;
			margin-top: 0.3rem;
			margin-left: 2rem;
			height: 15px;
			background-color: white;
			display: flex;
			justify-content: space-between;
			align-items: center;
		}
	}

	.van-checkbox {
		justify-content: center;
	}

	.title {
		padding: 5px 5px;
		font-size: 12px;
		line-height: 20px;
	}

	.price {
		padding-left: 10px;
		text-align: left;
		font-size: 16px;
		font-weight: bold;
		color: #ffba0b;
		display: flex;
		align-items: center;
	}

	.opration {
		padding-right: 10px;
		display: flex;
		align-items: center;
		justify-content: flex-end;
	}

	.red {
		color: #ffba0b;
		font-weight: bold;
		font-size: 16px;
	}

	.goods_item {
		display: flex;
		flex-direction: column;
		margin: 10px;
		// padding: 5px;
		background-color: white;
		border-radius: 10px;
		font-size: 14px;
		text-align: center;

		.price {
			margin: 0.5rem auto;
		}
	}
</style>
